package com.dhruvtaara.beta.toolset;

import java.util.Date;

public class DateUtil {

	/**
	 * 
	 * @return
	 */
	public static long getCurrentTime() {
		Date currentDate = new Date();
		return currentDate.getTime();
	}

	/**
	 * 
	 * @param time
	 * @return
	 */
	public static String getDefaultFormattedDate(long time) {
		Date d = new Date(time);
		return d.toString();
	}

	/**
	 * Compares time with the current time
	 * @param timeToCompare
	 * @param range
	 *            in minutes e.g. within 30 minutes
	 * @return
	 */
	public static boolean isTimeInRange(long timeToCompare, int range) {
		long ticks = range * 60 * 1000;
		long currentTime = DateUtil.getCurrentTime();
		if (currentTime - timeToCompare <= ticks)
			return true;
		if (timeToCompare - currentTime <= ticks)
			return true;
		return false;
	}

}
